package com.example.homework_20220930;

import java.util.*;

public class Main {
    public static void main(String[] args) {

        Collection<String> allType = new ArrayList<String>();
        allType.add("serious illness");
        allType.add("property");
        allType.add("health");

        String insuranceType = getInfo("Please enter the type of insurance(serious illness, property, health):"
                , allType);

        if(insuranceType.equals("serious illness")){
            new SeriousIllness();
        }else if(insuranceType.equals("property")){
            new Property();
        }else{
            new Health();
        }
    }
    public static String getInfo(String guideInfo, Collection<String> option){
        System.out.println(guideInfo);
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        if(option.contains(str)){
            return str;
        }else{
            System.out.println("Wrong input!");
            return getInfo(guideInfo, option);
        }
    }
    public static int getInfo(String guideInfo){
        System.out.println(guideInfo);
        Scanner sc = new Scanner(System.in);
        int value = sc.nextInt();
        if(value > 0){
            return value;
        }else{
            System.out.println("Wrong input!");
            return getInfo(guideInfo);
        }
    }
}